<?php

namespace common\models\datas;

use Yii;
use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "{{%recharge}}".
 *
 * @property integer $id
 * @property integer $customer_id
 * @property integer $site_id
 * @property string $cash
 * @property string $surplus_cash
 * @property integer $frequency
 * @property integer $created_at
 * @property integer $isuser_id
 */
class Recharge extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%recharge}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['customer_id', 'site_id', 'frequency', 'created_at', 'isuser_id'], 'integer'],
            [['cash', 'surplus_cash'], 'number'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', '自增id'),
            'customer_id' => Yii::t('common', '会员id'),
            'site_id' => Yii::t('common', '分店id'),
            'cash' => Yii::t('common', '充值金额'),
            'surplus_cash' => Yii::t('common', '剩余金额'),
            'frequency' => Yii::t('common', '充值次数'),
            'created_at' => Yii::t('common', '充值时间'),
            'isuser_id' => Yii::t('common', '教服id'),
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
                ],
            ],

        ]);
    }
}
